import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
import eslintPlugin from 'vite-plugin-eslint'

const resolve = (dir) => path.join(__dirname, dir)

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      dts: true,
      resolvers: [
        AntDesignVueResolver({ importStyle: 'less' })
      ]
    }),
    eslintPlugin({
      cache: false // 禁用eslint缓存
    })
  ],
  resolve: {
    alias: {
      '@': path.resolve('src')
    }
  },
  css: {
    preprocessorOptions: {
      less: {
        modifyVars: {
          hack: `true; @import "${resolve('./src/assets/style/theme.less')}";`
        },
        javascriptEnabled: true
      }
    }
  }
})
